package Demo2;

/**
 * Created with IntelliJ IDEA.
 * User: wenxiwen
 * Date: 2022/4/8
 * Time: 20:26
 * Description: No Description
 */
class Animal {
    public String name;

    public Animal(String name) {
        this.name = name;
    }

    public void eat() {
        System.out.println("这是一个父类的方法");
    }
}

interface A {
    void fun();//跑
}

interface B {
    void set();//游泳
}

interface C {
    void sun();//飞
}

class Cat extends Animal implements A, B {

    public Cat(String name) {
        super(name);
    }



    @Override
    public void fun() {
        System.out.println(this.name+"正在跑");
    }

    @Override
    public void set() {
        System.out.println(this.name+"正在游泳");
    }


}
class Duck extends Animal implements A, B, C {

    public Duck(String name) {
        super(name);
    }



    @Override
    public void fun() {
        System.out.println(this.name+"正在跑");
    }

    @Override
    public void set() {
        System.out.println(this.name+"正在游泳");
    }

    @Override
    public void sun() {
        System.out.println(this.name+"正在飞");
    }
}
class Dog extends Animal implements A, B {

    public Dog(String name) {
        super(name);
    }


    @Override
    public void fun() {
        System.out.println(this.name+"正在跑");
    }

    @Override
    public void set() {
        System.out.println(this.name+"正在游泳");
    }


}
public class TestDemo {
    public static void sleep(B b) {
        b.set();
    }

    public static void main(String[] args) {

        sleep(new Duck("鸭鸭"));
        sleep(new Cat("咪咪"));
        sleep(new Dog("狗狗"));

    }

    public static void seek(C c) {
        c.sun();
    }

    public static void main2(String[] args) {

        seek(new Duck("鸭鸭"));
    }

    public static void week(A a) {
        a.fun();
    }
    public static void main1(String[] args) {
        A animal = new Cat("咪咪");
        A animal1 = new Duck("鸭鸭");
        A animal2 = new Dog("狗狗");

        week(animal);
        week(animal1);
        week(animal2);
    }

}